import { AdColumn } from '@/components/AdVxeTable';
import { useI18n } from '@/hooks/web/useI18n';
import { getMessageTypeEnumSchema } from '@/enums/messageTypeEnum';
import { getMessageLevelEnumSchema } from '@/enums/messageLevelEnum';
import { getMessageSendWayEnumSchema } from '@/enums/messageSendWayEnum';

const { t } = useI18n();
const messageTypeEnumSchema = getMessageTypeEnumSchema();
const messageLevelEnumSchema = getMessageLevelEnumSchema();
const messageSendWayEnumSchema = getMessageSendWayEnumSchema();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    filterable: true,
    filterIndex: 'Id',
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.message.baseTypeText'),
    field: 'BaseType',
    width: 150,
    filterable: true,
    filterIndex: 'BaseType',
    dataType: 'string',
  },
  {
    title: t('routes.system.message.message.baseIdText'),
    field: 'BaseId',
    width: 150,
    filterable: true,
    filterIndex: 'BaseId',
    dataType: 'string',
  },
  {
    title: t('routes.system.message.methodText'),
    field: 'Method',
    width: 120,
    filterable: true,
    filterIndex: 'Method',
    dataType: 'string',
  },
  {
    title: t('routes.system.message.iconText'),
    field: 'Icon',
    width: 80,
    filterable: false,
    dataType: 'image',
  },
  {
    title: t('routes.system.message.messageTypeText'),
    field: 'MessageType',
    width: 95,
    filterable: true,
    dataType: 'enum',
    enumData: messageTypeEnumSchema,
  },
  {
    title: t('routes.system.message.messageLevelText'),
    field: 'MessageLevel',
    width: 95,
    filterable: true,
    dataType: 'enum',
    enumData: messageLevelEnumSchema,
  },
  {
    title: t('routes.system.message.titleText'),
    field: 'Title',
    width: 200,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.message.contentText'),
    field: 'Content',
    width: 300,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.message.payloadText'),
    field: 'Payload',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'string',
  },
  {
    title: t('routes.system.message.message.sendTimeText'),
    field: 'SendTime',
    width: 180,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('routes.system.message.sendWaysText'),
    field: 'SendWays',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'text',
  },
  {
    title: t('routes.system.message.toUsersText'),
    field: 'ToUsers',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'text',
  },
  {
    title: t('routes.system.message.toOrganizationsText'),
    field: 'ToOrganizations',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'text',
  },
  {
    title: t('routes.system.message.toRolesText'),
    field: 'ToRoles',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'text',
  },
  {
    title: t('routes.system.message.storageDaysText'),
    field: 'StorageDays',
    width: 80,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.message.isSystemText'),
    field: 'IsSystem',
    width: 80,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.message.message.senderIdText'),
    field: 'SenderId',
    width: 0,
    visible: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.message.senderNameText'),
    field: 'SenderName',
    width: 100,
    filterable: true,
    filterIndex: 'SenderId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.message.message.senderNicknameText'),
    field: 'SenderNickname',
    width: 100,
    filterable: true,
    filterIndex: 'SenderId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.message.message.isSentText'),
    field: 'IsSent',
    width: 80,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('entity.creationAudited.creatorIdTitle'),
    field: 'CreatorId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('entity.creationAudited.creatorNameTitle'),
    field: 'CreatorName',
    width: 100,
    filterable: true,
    formVisible: true,
    formEditable: false,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.creatorNicknameTitle'),
    field: 'CreatorNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('entity.updateAudited.updaterIdTitle'),
    field: 'UpdaterId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('entity.updateAudited.updaterNameTitle'),
    field: 'UpdaterName',
    width: 100,
    filterable: true,
    formVisible: true,
    formEditable: false,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updaterNicknameTitle'),
    field: 'UpdaterNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updatedTimeTitle'),
    field: 'UpdatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
];

export const receiverColumns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    filterable: true,
    filterIndex: 'Id',
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.messageIdText'),
    field: 'MessageId',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.message.receiverIdText'),
    field: 'ReceiverId',
    width: 0,
    visible: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.message.message.receiverNameText'),
    field: 'ReceiverName',
    width: 100,
    filterable: true,
    filterIndex: 'ReceiverId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.message.message.receiverNicknameText'),
    field: 'ReceiverNickname',
    width: 100,
    filterable: true,
    filterIndex: 'ReceiverId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.message.sendWaysText'),
    field: 'SendWays',
    width: 0,
    visible: false,
    filterable: false,
    dataType: 'text',
  },
  {
    title: t('routes.system.message.message.lastReadTimeText'),
    field: 'LastReadTime',
    width: 180,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('routes.system.message.message.lastReadWayText'),
    field: 'LastReadWay',
    width: 90,
    filterable: true,
    dataType: 'enum',
    enumData: messageSendWayEnumSchema,
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 180,
    filterable: true,
    dataType: 'datetime',
  },
];
